<template>
<div class="swiper-container">
    <!-- v-if的作用是当页面从index.json获取数据后再渲染, 不然会第一次进入页面是最后一个图 -->
    <swiper ref= "mySwiper" :options= "swiperOptions" v-if= 'swiperList.length'>
        <swiper-slide v-for= 'item in swiperList' :key= 'item.id'>
            <img class="swiper-img" :src= 'item.imgUrl'>
        </swiper-slide>
        <div class="swiper-pagination" slot="pagination"></div>
    </swiper>
</div>
</template>
<script>
export default {
    name: 'home-swipers',
    data() {
        return {
            swiperOptions: {
                pagination: '.swiper-pagination', //class名
                autoplay: 2500,
                loop: true
            }
        }
    },
    props: {
        swiperList: Array
    }
}
</script>

<style lang= "stylus" scoped>
.swiper-container >>> .swiper-pagination-bullet-active
    background-color #fff
*
    margin 0
    padding 0
    box-sizing border-box
    .swiper-container
        overflow hidden
        height 0
        padding-bottom 40%
        background-color #eee
        .swiper-img
            width 100%
</style>
